import fetch from "@/utils/fetch";

const userroles = {
  state: {
    role: ""
  },
  mutations: {
    GET_ROLE: (state, role) => {
      state.role = role;
    }
  },
  actions: {
    getuserrole({ commit }) {
      return new Promise((resolve, reject) => {
        fetch
          .userrole()
          .then(response => {
            const role = response.role;
            commit("GET_ROLE", role);
            resolve(response);
          })
          .catch(error => {
            reject(error);
          });
      });
    }
  }
};

export default userroles;
